import cookie from "../cookie.js"

let page = {
    before_amis_embed: function(json){
        let crud_name=json.body[0].name;
        json.body[0].filter.controls.push(
            {
                "type": "button",
                "label": "提给我的未解决",
                "level": "warning",
                "actionType": "reload",
                "target": crud_name+"?require_user=&to_user="+cookie.getcookie("emp_name")+"&status=开启"
            },
            {
                "type": "button",
                "label": "我提出的已修改",
                "level": "success",
                "actionType": "reload",
                "target": crud_name+"?require_user="+cookie.getcookie("emp_name")+"&to_user=&status=已修改"
            },
            {
                "type": "button",
                "label": "全部",
                "actionType": "reload",
                "target": crud_name+"?require_user=&to_user=&status="
            }
        )
    },
    after_handle_a_field: function(field,col){
        if(field.name=="status"){
            col.type="mapping";
            col.map={
                "关闭": "<span class='label label-info'>${status}</span>",
                "已修改": "<span class='label label-success'>${status}</span>",
                "开启": "<span class='label label-danger'>${status}</span>",
                "拒绝": "<span class='label label-warning'>${status}</span>",
                "*": "<span class='label label-default'>${status}</span>"
              }
        }
    }
};

export default page;